<template>
  <transition v-if="$route.meta.keepAlive"
              :name="transitionName">
    <keep-alive>
      <router-view class="child-view keepalive"></router-view>
    </keep-alive>
  </transition>
  <transition v-else
              :name="transitionName">
    <router-view class="child-view"></router-view>
  </transition>
</template>

<script>
export default {
  data () {
    return {
      transitionName: "fade"
    };
  },
  beforeRouteUpdate (to, from, next) {
    this.transitionName = "fade";
    next();
  }
};
</script>

<style scoped>
.pointer {
  cursor: pointer;
}
.child-view {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100%;
  box-sizing: border-box;
  transition-property: transform, opacity;
  transition-duration: 0.3s;
  transition-timing-function: ease-out;
  display: flex;
  flex-direction: column;
}
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s;
}
.fade-enter,
.fade-leave-to {
  opacity: 0;
}
</style>
